/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.feiyue.basic.server.parser;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import android.util.Xml;

public class Xml2ParseCategoryList {
	private List<Category> categoryList = new ArrayList();

	public Xml2ParseCategoryList(String paramString)
			throws XmlPullParserException, IOException {
		XmlPullParser localXmlPullParser = Xml.newPullParser();
		localXmlPullParser.setInput(
				new ByteArrayInputStream(paramString.getBytes()), null);
		Parser(localXmlPullParser);
	}

	private void Parser(XmlPullParser paramXmlPullParser)
    throws IOException, XmlPullParserException
  {
    Category localCategory = null;
    
    int eventType = paramXmlPullParser.getEventType();
    
    while (eventType != XmlPullParser.END_DOCUMENT) {
    	if (eventType == XmlPullParser.START_DOCUMENT) {
    		//start parser
    	} else if (eventType== XmlPullParser.START_TAG) {
    		String tagName = paramXmlPullParser.getName();
    		
    		if ("categorylist".equals(tagName)) {
    		} else if ("category".equals(tagName)) {
    			localCategory = new Category();
    		} else if ("coveraddr".equals(tagName)) {
    			paramXmlPullParser.next();
    	        localCategory.setCoverAddr(paramXmlPullParser.getText());
    		} else if ("id".equals(tagName)) {
    			paramXmlPullParser.next();
    		      localCategory.setId(Integer.valueOf(paramXmlPullParser.getText()).intValue());
    		} else if ("name".equals(tagName)) {
    			paramXmlPullParser.next();
    	        localCategory.setName(paramXmlPullParser.getText());
    		}
    	} else if (eventType== XmlPullParser.END_TAG) {
    		String tagName = paramXmlPullParser.getName();
    		
    		if ("categorylist".equals(tagName)) {
    		} else if ("category".equals(tagName)) {
    			this.categoryList.add(localCategory);
    		} else if ("coveraddr".equals(tagName)) {
    		} else if ("id".equals(tagName)) {
    		} else if ("name".equals(tagName)) {
    		}
    	}

    	eventType = paramXmlPullParser.next();
    }
  }

	public List<Category> getCategoryList() {
		return this.categoryList;
	}

	public void setCategoryList(List<Category> paramList) {
		this.categoryList = paramList;
	}
}